import { fileURLToPath } from 'url'

import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
      imports: ['vue'],
      // dts: true,
      dts: fileURLToPath(new URL('./auto-imports.d.ts', import.meta.url))
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    })
  ],
  resolve: {
    alias: {
      '~assets': fileURLToPath(new URL('./assets', import.meta.url)),
      '~locales': fileURLToPath(new URL('./locales', import.meta.url)),
      '~theme': fileURLToPath(new URL('./theme', import.meta.url)),
      '~utils': fileURLToPath(new URL('./utils', import.meta.url)),
      '~stores': fileURLToPath(new URL('./stores', import.meta.url)),
      '~comp': fileURLToPath(new URL('./components', import.meta.url)),
      '~hooks': fileURLToPath(new URL('./hooks', import.meta.url))
    }
  },
  server: {
    open: true,
    host: '0.0.0.0'
  }
})
